home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / edgetext / clstime_.cl_ / clstime_.cl
Encoding:
Text File  |  1998-03-21  |  56.8 KB  |  1,556 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. End
  5. Attribute VB_Name = "clsTime_log"
  6. Attribute VB_Creatable = True
  7. Attribute VB_PredeclaredId = False
  8. Attribute VB_Exposed = False
  9. Option Explicit
  10. '**************************************************************************************
  11. 'Title:     clsTime_log.cls 
  12. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  13. 'Purpose:   This class allows single record access to the Time_log Table 
  14. 'Properties:Equate to the fields in the table
  15. 'Methods:   Allow for record manipulation
  16.  
  17.  
  18. 'It is recommended that the Database object Dbtimesheet be declared global
  19.  
  20. 'It is also recommended that the Configuration object be declared global if it is being used
  21. 'This is so that it can be persistent
  22. '**************************************************************************************
  23.  
  24. 'Here are the Field Properties for this table Class
  25. Public Reporting_Day as String
  26. Public Client as Integer
  27. Public Rate as Integer
  28. Public In_Time1 as String
  29. Public Out_Time1 as String
  30. Public In_Time2 as String
  31. Public Out_Time2 as String
  32. Public Total_Time as Single
  33. Public Comments as String
  34. Public Updated_By as String
  35. Public Update_Module as String
  36. Public Update_Time as String
  37.  
  38. 'These are the ScratchPad Variables
  39. Private mReporting_Day as String
  40. Private mClient as Integer
  41. Private mRate as Integer
  42. Private mIn_Time1 as String
  43. Private mOut_Time1 as String
  44. Private mIn_Time2 as String
  45. Private mOut_Time2 as String
  46. Private mTotal_Time as Single
  47. Private mComments as String
  48. Private mUpdated_By as String
  49. Private mUpdate_Module as String
  50. Private mUpdate_Time as String
  51.  
  52. 'This public variable tells whether a function was successful, it is True when a function
  53. 'is successful, and false when a function is unsuccessful
  54. Public Success as Boolean
  55. 'This is the Error Code which was generated in the function call, it matches Err from VB
  56. Public ErrorCode as Double
  57. 'This is the Error message which was generated in the function call, it matches Errors(0) VB
  58. Public ErrorMessage as String
  59. 'This Constant tells the error traps how many retries to perform
  60. Private Const MaxRetries = 4
  61.  
  62. '********************************************************************************************************
  63. 'Title:     CreateTable
  64. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  65. 'Purpose:   This subroutine Creates the very table that this class was created to read and write    
  66. 'Parameters:None
  67. 'Return:    Nothing
  68. '********************************************************************************************************
  69. Public Sub CreateTable()
  70.  
  71. Dim lsCreate as string
  72. Dim RetCode as integer, liCount as integer, BadCount as integer
  73.  
  74.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  75.     Success = True
  76.     'The ErrorCode is the Err returned by VB for the Trapped Error
  77.     ErrorCode = False
  78.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  79.     If Not objConfiguration.DebugFlag Then
  80.         On Error GoTo NoTime_logCreateTable
  81.     End If
  82.  
  83.  
  84.     'Assemble the SQL String
  85.     lsCreate = "Create Table TIME_LOG ("
  86.     lsCreate = lsCreate & "Reporting_Day Date/Time(8),"
  87.     lsCreate = lsCreate & "Client Integer(2),"
  88.     lsCreate = lsCreate & "Rate Integer(2),"
  89.     lsCreate = lsCreate & "In_Time1 Date/Time(8),"
  90.     lsCreate = lsCreate & "Out_Time1 Date/Time(8),"
  91.     lsCreate = lsCreate & "In_Time2 Date/Time(8),"
  92.     lsCreate = lsCreate & "Out_Time2 Date/Time(8),"
  93.     lsCreate = lsCreate & "Total_Time Single(4),"
  94.     lsCreate = lsCreate & "Comments String(255),"
  95.     lsCreate = lsCreate & "Updated_By String(50),"
  96.     lsCreate = lsCreate & "Update_Module String(50),"
  97.     lsCreate = lsCreate & "Update_Time Date/Time(8))"
  98.  
  99.     'Execute the SQL
  100.     Dbtimesheet.Execute lsCreate
  101.     On Error GoTo 0
  102.     Exit Sub
  103.  
  104. NoTime_logCreateTable:
  105.  
  106.     'Retry for a predermined number of times, set by the MaxRetries Constant
  107.     If BadCount < MaxRetries Then
  108.         'if we have been exceeded retries on a previous error in this routine,
  109.         'just give the remaining errors one try, and don't save these errors,
  110.         'the interest should be in the original error
  111.         If Success = False Then
  112.             Resume Next
  113.         Else
  114.             'increment the retry counter
  115.             BadCount = BadCount + 1
  116.             'Look for Database errors and see if you can fix the error by reconnecting
  117.             If Err = 3146 or Err = 3075 then
  118.                 'Try Reconnecting to the database, then
  119.                 'keep executing the same line of code in a hope that retries will
  120.                 'be the solution to the problem.
  121.                 On Error GoTo BadTime_logCreateTableConnect
  122.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  123.                 On Error goto 0
  124.             End If
  125.             Resume 0
  126.         End If
  127.     Else
  128.         'At MaxRetries, flag a failure in the routine
  129.         Success = False
  130.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  131.         'get a reason why the error occurred
  132.         ErrorCode = Err
  133.         objError.ErrorCode = Err
  134.         objError.FunctionName = "clsTime_log.CreateTable"
  135.         If Err = 3146 then
  136.             objError.Message = "Time_log, CreateTable " & vbcrlf & Errors(0) & " "
  137.             ErrorMessage = Errors(0)
  138.         Else
  139.             objError.Message = "Time_log, CreateTable "
  140.             ErrorMessage = Error(Err)
  141.         End If
  142.         objError.SQL = lsCreate
  143.         objError.Display vbExclamation
  144.         'reset the counter
  145.         BadCount = 0
  146.         'and try to execute the next line of code in the routine
  147.         Resume Next
  148.     End If
  149.  
  150. BadTime_logCreateTableConnect:
  151.     'You can put additional database reopening error checking here if necessary
  152.     Resume Next
  153.  
  154.  
  155. End Sub
  156.  
  157.  
  158. '********************************************************************************************************
  159. 'Title:     AddItem
  160. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  161. 'Purpose:   This method Adds Items to the Database after the Key properties
  162. '           of the class have been filled
  163. 'Parameters:None
  164. 'Return:    Nothing
  165. '********************************************************************************************************
  166. Public Sub AddItem()
  167.  
  168. Dim lsAdd as string
  169. Dim RetCode as integer, liCount as integer, BadCount as integer
  170.  
  171.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  172.     Success = True
  173.     'The ErrorCode is the Err returned by VB for the Trapped Error
  174.     ErrorCode = False
  175.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  176.     If Not objConfiguration.DebugFlag Then
  177.         On Error GoTo NoTime_logAddItem
  178.     End If
  179.  
  180.     'First we assign all the properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  181.     StoreProperties
  182.     SetDefaultDates
  183.  
  184.     'Now Pad fields with a space if the record cannot be added with zero length
  185.     PadFields
  186.  
  187.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  188.     DoubleYourQuotes
  189.  
  190.     'Assemble the SQL String
  191.     lsAdd = "Insert into TIME_LOG ("
  192.     'First the Field List
  193.     lsAdd = lsAdd & "Reporting_Day,"
  194.     lsAdd = lsAdd & "Client,"
  195.     lsAdd = lsAdd & "Rate,"
  196.     lsAdd = lsAdd & "In_Time1,"
  197.     lsAdd = lsAdd & "Out_Time1,"
  198.     lsAdd = lsAdd & "In_Time2,"
  199.     lsAdd = lsAdd & "Out_Time2,"
  200.     lsAdd = lsAdd & "Total_Time,"
  201.     lsAdd = lsAdd & "Comments,"
  202.     lsAdd = lsAdd & "Updated_By,"
  203.     lsAdd = lsAdd & "Update_Module,"
  204.     lsAdd = lsAdd & "Update_Time)"
  205.     lsAdd = lsAdd & " Values("
  206.     'Now the Value List
  207.     lsAdd = lsAdd & "" & Reporting_Day & ","
  208.     lsAdd = lsAdd & "" & Format(Client) & ","
  209.     lsAdd = lsAdd & "" & Format(Rate) & ","
  210.     lsAdd = lsAdd & "" & In_Time1 & ","
  211.     lsAdd = lsAdd & "" & Out_Time1 & ","
  212.     lsAdd = lsAdd & "" & In_Time2 & ","
  213.     lsAdd = lsAdd & "" & Out_Time2 & ","
  214.     lsAdd = lsAdd & "" & Format(Total_Time) & ","
  215.     lsAdd = lsAdd & "'" & Comments & "',"
  216.     'These are the Audit Trail Fields
  217.     lsAdd = lsAdd & "'" & objConfiguration.LanId & "',"
  218.     lsAdd = lsAdd & "'" & objConfiguration.ModuleName & "',"
  219.     lsAdd = lsAdd & "#" & format(Now,"MM/DD/YYYY hh:mm:ss") & "#)"
  220.  
  221.     'Execute the SQL
  222.     Dbtimesheet.Execute lsAdd
  223.  
  224.     'Reassign the original values to the properties list
  225.     RetrieveProperties
  226.  
  227.     On Error GoTo 0
  228.     Exit Sub
  229.  
  230. NoTime_logAddItem:
  231.  
  232.     'Retry for a predermined number of times, set by the MaxRetries Constant
  233.     If BadCount < MaxRetries Then
  234.         'if we have been exceeded retries on a previous error in this routine,
  235.         'just give the remaining errors one try, and don't save these errors,
  236.         'the interest should be in the original error
  237.         If Success = False Then
  238.             Resume Next
  239.         Else
  240.             'increment the retry counter
  241.             BadCount = BadCount + 1
  242.             'Look for Database errors and see if you can fix the error by reconnecting
  243.             If Err = 3146 or Err = 3075 then
  244.                 'Try Reconnecting to the database, then
  245.                 'keep executing the same line of code in a hope that retries will
  246.                 'be the solution to the problem.
  247.                 On Error GoTo BadTime_logAddItemConnect
  248.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  249.                 On Error goto 0
  250.             End If
  251.             Resume 0
  252.         End If
  253.     Else
  254.         'At MaxRetries, flag a failure in the routine
  255.         Success = False
  256.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  257.         'get a reason why the error occurred
  258.         ErrorCode = Err
  259.         objError.ErrorCode = Err
  260.         objError.FunctionName = "clsTime_log.AddItem"
  261.         If Err = 3146 then
  262.             objError.Message = "Time_log, AddItem " & vbcrlf & Errors(0) & " "
  263.             ErrorMessage = Errors(0)
  264.         Else
  265.             objError.Message = "Time_log, AddItem "
  266.             ErrorMessage = Error(Err)
  267.         End If
  268.         objError.SQL = lsAdd
  269.         objError.Display vbExclamation
  270.         'reset the counter
  271.         BadCount = 0
  272.         'and try to execute the next line of code in the routine
  273.         Resume Next
  274.     End If
  275.  
  276. BadTime_logAddItemConnect:
  277.     'You can put additional database reopening error checking here if necessary
  278.     Resume Next
  279.  
  280.  
  281. End Sub
  282.  
  283. '********************************************************************************************************
  284. 'Title:     ClearValues
  285. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  286. 'Purpose:   This method clears all fields in the Table class
  287. 'Parameters:None
  288. 'Return:    Nothing
  289. '********************************************************************************************************
  290. Sub ClearValues()
  291.  
  292.     Reporting_Day = ""
  293.     Client = 0
  294.     Rate = 0
  295.     In_Time1 = ""
  296.     Out_Time1 = ""
  297.     In_Time2 = ""
  298.     Out_Time2 = ""
  299.     Total_Time = 0
  300.     Comments = ""
  301.     Updated_By = ""
  302.     Update_Module = ""
  303.     Update_Time = ""
  304.  
  305. End Sub
  306.  
  307.  
  308. '********************************************************************************************************
  309. 'Title:     DeleteItem
  310. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  311. 'Purpose:   This method Deletes Items from the Database after the Key fields have been filled
  312. 'Parameters:None
  313. 'Return:    Nothing
  314. '********************************************************************************************************
  315. Public Sub DeleteItem()
  316.  
  317. Dim lrsTime_log as RecordSet, lsDelete as string
  318. Dim RetCode as integer,lsCount as integer,liCount as integer,BadCount as integer
  319.  
  320.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  321.     Success = True
  322.     'The ErrorCode is the Err returned by VB for the Trapped Error
  323.     ErrorCode = False
  324.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  325.     If Not objConfiguration.DebugFlag Then
  326.         On Error GoTo NoTime_logDeleteItem
  327.     End If
  328.  
  329.     'First we assign all the properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  330.     StoreProperties
  331.     SetDefaultDates
  332.  
  333.     'Now Pad fields with a space if the record cannot be added with zero length
  334.     PadFields
  335.  
  336.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  337.     DoubleYourQuotes
  338.  
  339.     'Assemble the SQL String
  340.     lsDelete = "Delete from TIME_LOG  where Reporting_Day = " & Reporting_Day & " and Client = " & Format(Client) & ""
  341.  
  342.     'Execute the SQL
  343.      Dbtimesheet.Execute lsDelete
  344.  
  345.     'Now ReAssign the Temp vars back to the class props
  346.     RetrieveProperties
  347.  
  348.     On Error GoTo 0
  349.     Exit Sub
  350.  
  351. NoTime_logDeleteItem:
  352.  
  353.     'Retry for a predermined number of times, set by the MaxRetries Constant
  354.     If BadCount < MaxRetries Then
  355.         'if we have been exceeded retries on a previous error in this routine,
  356.         'just give the remaining errors one try, and don't save these errors,
  357.         'the interest should be in the original error
  358.         If Success = False Then
  359.             Resume Next
  360.         Else
  361.             'increment the retry counter
  362.             BadCount = BadCount + 1
  363.             'Look for Database errors and see if you can fix the error by reconnecting
  364.             If Err = 3146 or Err = 3075 then
  365.                 'Try Reconnecting to the database, then
  366.                 'keep executing the same line of code in a hope that retries will
  367.                 'be the solution to the problem.
  368.                 On Error GoTo BadTime_logDeleteItemConnect
  369.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  370.                 On Error goto 0
  371.             End If
  372.             Resume 0
  373.         End If
  374.     Else
  375.         'At MaxRetries, flag a failure in the routine
  376.         Success = False
  377.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  378.         'get a reason why the error occurred
  379.         ErrorCode = Err
  380.         objError.ErrorCode = Err
  381.         objError.FunctionName = "clsTime_log.DeleteItem"
  382.         If Err = 3146 then
  383.             objError.Message = "Time_log, DeleteItem " & vbcrlf & Errors(0) & " "
  384.             ErrorMessage = Errors(0)
  385.         Else
  386.             objError.Message = "Time_log, DeleteItem "
  387.             ErrorMessage = Error(Err)
  388.         End If
  389.         objError.SQL = lsDelete
  390.         objError.Display vbExclamation
  391.         'reset the counter
  392.         BadCount = 0
  393.         'and try to execute the next line of code in the routine
  394.         Resume Next
  395.     End If
  396.  
  397. BadTime_logDeleteItemConnect:
  398.     'You can put additional database reopening error checking here if necessary
  399.     Resume Next
  400.  
  401.  
  402. End Sub
  403.  
  404.  
  405. '********************************************************************************************************
  406. 'Title:     FillObjectFromRecordset
  407. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  408. 'Purpose    This sub fills all the properties of the class from a given recordset
  409. 'Parameters:The recordset from which to fill
  410. 'Return:    Nothing
  411. '********************************************************************************************************
  412. Public Sub FillObjectFromRecordSet(lrsTime_log as RecordSet)
  413.  
  414. Dim liCount as Integer, BadCount as Integer, pSQL as String, lsSelect as String
  415.     If Not objConfiguration.DebugFlag Then
  416.         On Error GoTo NoTime_logFillObject
  417.     End If
  418.  
  419.     'Appending a & "" onto the end of a recordset field checks for Null values
  420.     'Similarly, Numbers are explicitly converted to eliminate Null values as well
  421.     Reporting_Day = lrsTime_log![Reporting_Day] & ""
  422.     Client = Val(lrsTime_log![Client] & "")
  423.     Rate = Val(lrsTime_log![Rate] & "")
  424.     In_Time1 = lrsTime_log![In_Time1] & ""
  425.     Out_Time1 = lrsTime_log![Out_Time1] & ""
  426.     In_Time2 = lrsTime_log![In_Time2] & ""
  427.     Out_Time2 = lrsTime_log![Out_Time2] & ""
  428.     Total_Time = Val(lrsTime_log![Total_Time] & "")
  429.     Comments = lrsTime_log![Comments] & ""
  430.     Updated_By = lrsTime_log![Updated_By] & ""
  431.     Update_Module = lrsTime_log![Update_Module] & ""
  432.     Update_Time = lrsTime_log![Update_Time] & ""
  433.     On Error GoTo 0
  434.     Exit Sub
  435.  
  436. NoTime_logFillObject:
  437.  
  438.     'Retry for a predermined number of times, set by the MaxRetries Constant
  439.     If BadCount < MaxRetries Then
  440.         'if we have been exceeded retries on a previous error in this routine,
  441.         'just give the remaining errors one try, and don't save these errors,
  442.         'the interest should be in the original error
  443.         If Success = False Then
  444.             Resume Next
  445.         Else
  446.             'increment the retry counter
  447.             BadCount = BadCount + 1
  448.             'Look for Database errors and see if you can fix the error by reconnecting
  449.             If Err = 3146 or Err = 3075 then
  450.                 'Try Reconnecting to the database, then
  451.                 'keep executing the same line of code in a hope that retries will
  452.                 'be the solution to the problem.
  453.                 On Error GoTo BadTime_logFillObjectConnect
  454.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  455.                 On Error goto 0
  456.             End If
  457.             Resume 0
  458.         End If
  459.     Else
  460.         'At MaxRetries, flag a failure in the routine
  461.         Success = False
  462.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  463.         'get a reason why the error occurred
  464.         ErrorCode = Err
  465.         objError.ErrorCode = Err
  466.         objError.FunctionName = "clsTime_log.FillObject"
  467.         If Err = 3146 then
  468.             objError.Message = "Time_log, FillObject " & vbcrlf & Errors(0) & " "
  469.             ErrorMessage = Errors(0)
  470.         Else
  471.             objError.Message = "Time_log, FillObject "
  472.             ErrorMessage = Error(Err)
  473.         End If
  474.         objError.SQL = lsSelect
  475.         objError.Display vbExclamation
  476.         'reset the counter
  477.         BadCount = 0
  478.         'and try to execute the next line of code in the routine
  479.         Resume Next
  480.     End If
  481.  
  482. BadTime_logFillObjectConnect:
  483.     'You can put additional database reopening error checking here if necessary
  484.     Resume Next
  485.  
  486.  
  487. End Sub
  488.  
  489.  
  490. '********************************************************************************************************
  491. 'Title:     GetItem
  492. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  493. 'Purpose:   This Method Gets a record from the database after the Key Fields have been Filled
  494. 'Parameters:The recordset from which to fill
  495. 'Return:    Nothing
  496. '********************************************************************************************************
  497. Public Sub GetItem()
  498.  
  499. Dim lrsGetItem as RecordSet, lsSelect as string
  500. Dim RetCode as integer,lsCount as integer,liCount as integer,BadCount as integer
  501.  
  502.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  503.     Success = True
  504.     'The ErrorCode is the Err returned by VB for the Trapped Error
  505.     ErrorCode = False
  506.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  507.     If Not objConfiguration.DebugFlag Then
  508.         On Error GoTo NoTime_logGetItem
  509.     End If
  510.  
  511.     'First we assign all the properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  512.     StoreProperties
  513.     SetDefaultDates
  514.  
  515.     'Now Pad fields with a space if the record cannot be added with zero length
  516.     PadFields
  517.  
  518.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  519.     DoubleYourQuotes
  520.  
  521.     'Assemble the SQL String
  522.     lsSelect = "Select * from TIME_LOG  where Reporting_Day = " & Reporting_Day & " and Client = " & Format(Client) & ""
  523.  
  524.     'Execute the SQL
  525.      Set lrsGetItem = Dbtimesheet.OpenRecordSet(lsSelect)
  526.  
  527.     'Now ReAssign the Temp vars back to the class props
  528.     RetrieveProperties
  529.  
  530.     'Check for a valid record
  531.     If Not Success Then
  532.         Exit Sub
  533.     End If
  534.     If lrsGetItem.RecordCount = 0 Then
  535.         Success = False
  536.         Exit Sub
  537.     End If
  538.  
  539.     'Fill the Table Class Fields from the Recordset
  540.     FillObjectFromRecordset lrsGetItem
  541.     'Check for Errors    
  542.     if not Success then
  543.         Exit sub
  544.     end if
  545.     lrsGetItem.Close
  546.  
  547.     'Now trim the spaces out of the padded fields
  548.     TrimPaddedFields
  549.  
  550.     'Strip the NULLs or bad dates out of date fields
  551.     StripDates False
  552.  
  553.     On Error GoTo 0
  554.     Exit Sub
  555.  
  556. NoTime_logGetItem:
  557.  
  558.     'Retry for a predermined number of times, set by the MaxRetries Constant
  559.     If BadCount < MaxRetries Then
  560.         'if we have been exceeded retries on a previous error in this routine,
  561.         'just give the remaining errors one try, and don't save these errors,
  562.         'the interest should be in the original error
  563.         If Success = False Then
  564.             Resume Next
  565.         Else
  566.             'increment the retry counter
  567.             BadCount = BadCount + 1
  568.             'Look for Database errors and see if you can fix the error by reconnecting
  569.             If Err = 3146 or Err = 3075 then
  570.                 'Try Reconnecting to the database, then
  571.                 'keep executing the same line of code in a hope that retries will
  572.                 'be the solution to the problem.
  573.                 On Error GoTo BadTime_logGetItemConnect
  574.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  575.                 On Error goto 0
  576.             End If
  577.             Resume 0
  578.         End If
  579.     Else
  580.         'At MaxRetries, flag a failure in the routine
  581.         Success = False
  582.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  583.         'get a reason why the error occurred
  584.         ErrorCode = Err
  585.         objError.ErrorCode = Err
  586.         objError.FunctionName = "clsTime_log.GetItem"
  587.         If Err = 3146 then
  588.             objError.Message = "Time_log, GetItem " & vbcrlf & Errors(0) & " "
  589.             ErrorMessage = Errors(0)
  590.         Else
  591.             objError.Message = "Time_log, GetItem "
  592.             ErrorMessage = Error(Err)
  593.         End If
  594.         objError.SQL = lsSelect
  595.         objError.Display vbExclamation
  596.         'reset the counter
  597.         BadCount = 0
  598.         'and try to execute the next line of code in the routine
  599.         Resume Next
  600.     End If
  601.  
  602. BadTime_logGetItemConnect:
  603.     'You can put additional database reopening error checking here if necessary
  604.     Resume Next
  605.  
  606.  
  607. End Sub
  608.  
  609.  
  610. '********************************************************************************************************
  611. 'Title:     GetNewId
  612. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  613. 'Purpose:   This Method Gets a new Id using the Max function in SQL, it has only limited value, but is included as
  614. '           a template for new Primary Key generation
  615. 'Parameters:None
  616. 'Return:    Nothing
  617. '********************************************************************************************************
  618. Public function GetNewId() as double
  619.  
  620. Dim lrsGetNewId as RecordSet, lsSelect as string
  621. Dim RetCode as integer,liCount as integer,BadCount as integer
  622.  
  623.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  624.     Success = True
  625.     'The ErrorCode is the Err returned by VB for the Trapped Error
  626.     ErrorCode = False
  627.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  628.     If Not objConfiguration.DebugFlag Then
  629.         On Error GoTo NoTime_logGetNewId
  630.     End If
  631.  
  632.     'First we assign all the date and text properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  633.     StoreProperties
  634.     SetDefaultDates
  635.  
  636.     'Now Pad fields with a space if the record cannot be added with zero length
  637.     PadFields
  638.  
  639.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  640.     DoubleYourQuotes
  641.  
  642.  
  643.     'The SQL provided here is just a simple Get Max.  This would only be useful for very small tables
  644.     'If you anticipate this table growing past a few hundred rows, change this routine accordingly
  645.     'You might try keeping a table with the last Id stored as a field, which can then be updated when a 
  646.     'new Id is required.
  647.  
  648.     'Assemble the SQL String
  649.     lsSelect = "Select Max() from TIME_LOG  where Reporting_Day = " & Reporting_Day & ""
  650.  
  651.     'Execute the SQL
  652.     Set lrsGetNewId = Dbtimesheet.OpenRecordSet(lsSelect)
  653.  
  654.     'Now ReAssign the Temp vars back to the class props
  655.     RetrieveProperties
  656.  
  657.     'Don't forget to check for those NULLS
  658.     If Not IsNull(lrsGetNewId(0)) Then
  659.         GetNewId = lrsGetNewId(0) + 1
  660.     Else
  661.         GetNewId = 1
  662.     End If
  663.     lrsGetNewId.Close
  664.     On Error GoTo 0
  665.     Exit Function
  666.  
  667. NoTime_logGetNewId:
  668.  
  669.     'Retry for a predermined number of times, set by the MaxRetries Constant
  670.     If BadCount < MaxRetries Then
  671.         'if we have been exceeded retries on a previous error in this routine,
  672.         'just give the remaining errors one try, and don't save these errors,
  673.         'the interest should be in the original error
  674.         If Success = False Then
  675.             Resume Next
  676.         Else
  677.             'increment the retry counter
  678.             BadCount = BadCount + 1
  679.             'Look for Database errors and see if you can fix the error by reconnecting
  680.             If Err = 3146 or Err = 3075 then
  681.                 'Try Reconnecting to the database, then
  682.                 'keep executing the same line of code in a hope that retries will
  683.                 'be the solution to the problem.
  684.                 On Error GoTo BadTime_logGetNewIdConnect
  685.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  686.                 On Error goto 0
  687.             End If
  688.             Resume 0
  689.         End If
  690.     Else
  691.         'At MaxRetries, flag a failure in the routine
  692.         Success = False
  693.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  694.         'get a reason why the error occurred
  695.         ErrorCode = Err
  696.         objError.ErrorCode = Err
  697.         objError.FunctionName = "clsTime_log.GetNewId"
  698.         If Err = 3146 then
  699.             objError.Message = "Time_log, GetNewId " & vbcrlf & Errors(0) & " "
  700.             ErrorMessage = Errors(0)
  701.         Else
  702.             objError.Message = "Time_log, GetNewId "
  703.             ErrorMessage = Error(Err)
  704.         End If
  705.         objError.SQL = lsSelect
  706.         objError.Display vbExclamation
  707.         'reset the counter
  708.         BadCount = 0
  709.         'and try to execute the next line of code in the routine
  710.         Resume Next
  711.     End If
  712.  
  713. BadTime_logGetNewIdConnect:
  714.     'You can put additional database reopening error checking here if necessary
  715.     Resume Next
  716.  
  717.  
  718. End Function
  719.  
  720.  
  721. '********************************************************************************************************
  722. 'Title:     ParseItem
  723. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  724. 'Purpose:   This method can parse fields which have values in them.  It will create an SQL criteria string
  725. '           using like statements for strings, and = statements for numbers and dates, this can be used
  726. '           in Query by Example screens with little or no modification
  727. 'Parameters:None
  728. 'Return:    The Parsed String for use in SQL
  729. '********************************************************************************************************
  730. Public Function ParseItem(piAndFlag as Integer) As String
  731.  
  732. Dim RetCode as integer,liCount as integer,Buf1 as String
  733. Dim BadCount as integer, WildCard As String
  734.  
  735.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  736.     Success = True
  737.     'The ErrorCode is the Err returned by VB for the Trapped Error
  738.     ErrorCode = False
  739.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  740.     If Not objConfiguration.DebugFlag Then
  741.         On Error GoTo NoTime_logParseItem
  742.     End If
  743.  
  744.     'Change this based on your database, MS-Access uses the *, but SQL standard is the %
  745.     wildcard = "*'"
  746.     
  747.     'First we assign all the date and text properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  748.     StoreProperties
  749.     SetDefaultDates
  750.  
  751.     'Now Pad fields with a space if the record cannot be added with zero length
  752.     PadFields
  753.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  754.     DoubleYourQuotes
  755.  
  756.  
  757.     if isDate(Reporting_Day) then
  758.         If piAndFlag Then
  759.             Buf1 = Buf1 & " And "
  760.         Else
  761.             Buf1 = Buf1 & " Where "
  762.         End If
  763.         Buf1 = Buf1 & "Time_log.Reporting_Day = " & Reporting_Day
  764.         piAndFlag = True
  765.     End If
  766.  
  767.     If Client <> 0 Then
  768.         If piAndFlag Then
  769.             Buf1 = Buf1 & " And "
  770.         Else
  771.             Buf1 = Buf1 & " Where "
  772.         End If
  773.         Buf1 = Buf1 & "Time_log.Client = " & Format(Client)
  774.         piAndFlag = True
  775.     End If
  776.  
  777.     If Rate <> 0 Then
  778.         If piAndFlag Then
  779.             Buf1 = Buf1 & " And "
  780.         Else
  781.             Buf1 = Buf1 & " Where "
  782.         End If
  783.         Buf1 = Buf1 & "Time_log.Rate = " & Format(Rate)
  784.         piAndFlag = True
  785.     End If
  786.  
  787.     if isDate(In_Time1) then
  788.         If piAndFlag Then
  789.             Buf1 = Buf1 & " And "
  790.         Else
  791.             Buf1 = Buf1 & " Where "
  792.         End If
  793.         Buf1 = Buf1 & "Time_log.In_Time1 = " & In_Time1
  794.         piAndFlag = True
  795.     End If
  796.  
  797.     if isDate(Out_Time1) then
  798.         If piAndFlag Then
  799.             Buf1 = Buf1 & " And "
  800.         Else
  801.             Buf1 = Buf1 & " Where "
  802.         End If
  803.         Buf1 = Buf1 & "Time_log.Out_Time1 = " & Out_Time1
  804.         piAndFlag = True
  805.     End If
  806.  
  807.     if isDate(In_Time2) then
  808.         If piAndFlag Then
  809.             Buf1 = Buf1 & " And "
  810.         Else
  811.             Buf1 = Buf1 & " Where "
  812.         End If
  813.         Buf1 = Buf1 & "Time_log.In_Time2 = " & In_Time2
  814.         piAndFlag = True
  815.     End If
  816.  
  817.     if isDate(Out_Time2) then
  818.         If piAndFlag Then
  819.             Buf1 = Buf1 & " And "
  820.         Else
  821.             Buf1 = Buf1 & " Where "
  822.         End If
  823.         Buf1 = Buf1 & "Time_log.Out_Time2 = " & Out_Time2
  824.         piAndFlag = True
  825.     End If
  826.  
  827.     If Total_Time <> 0 Then
  828.         If piAndFlag Then
  829.             Buf1 = Buf1 & " And "
  830.         Else
  831.             Buf1 = Buf1 & " Where "
  832.         End If
  833.         Buf1 = Buf1 & "Time_log.Total_Time = " & Format(Total_Time)
  834.         piAndFlag = True
  835.     End If
  836.  
  837.     If Trim(Comments) <> "" Then
  838.         If piAndFlag Then
  839.             Buf1 = Buf1 & " And "
  840.         Else
  841.             Buf1 = Buf1 & " Where "
  842.         End If
  843.         Buf1 = Buf1 & "Time_log.Comments like '" & Trim(Comments) & WildCard
  844.         piAndFlag = True
  845.     End If
  846.  
  847.     If Trim(Updated_By) <> "" Then
  848.         If piAndFlag Then
  849.             Buf1 = Buf1 & " And "
  850.         Else
  851.             Buf1 = Buf1 & " Where "
  852.         End If
  853.         Buf1 = Buf1 & "Time_log.Updated_By like '" & Trim(Updated_By) & WildCard
  854.         piAndFlag = True
  855.     End If
  856.  
  857.     If Trim(Update_Module) <> "" Then
  858.         If piAndFlag Then
  859.             Buf1 = Buf1 & " And "
  860.         Else
  861.             Buf1 = Buf1 & " Where "
  862.         End If
  863.         Buf1 = Buf1 & "Time_log.Update_Module like '" & Trim(Update_Module) & WildCard
  864.         piAndFlag = True
  865.     End If
  866.  
  867.     if isDate(Update_Time) then
  868.         If piAndFlag Then
  869.             Buf1 = Buf1 & " And "
  870.         Else
  871.             Buf1 = Buf1 & " Where "
  872.         End If
  873.         Buf1 = Buf1 & "Time_log.Update_Time = " & Update_Time
  874.         piAndFlag = True
  875.     End If
  876.  
  877.     'now reassign the temp values back to the properties
  878.     RetrieveProperties
  879.  
  880.     On Error GoTo 0
  881.     ParseItem = Buf1
  882.     Exit Function
  883.  
  884. NoTime_logParseItem:
  885.  
  886.     'Retry for a predermined number of times, set by the MaxRetries Constant
  887.     If BadCount < MaxRetries Then
  888.         'if we have been exceeded retries on a previous error in this routine,
  889.         'just give the remaining errors one try, and don't save these errors,
  890.         'the interest should be in the original error
  891.         If Success = False Then
  892.             Resume Next
  893.         Else
  894.             'increment the retry counter
  895.             BadCount = BadCount + 1
  896.             'Look for Database errors and see if you can fix the error by reconnecting
  897.             If Err = 3146 or Err = 3075 then
  898.                 'Try Reconnecting to the database, then
  899.                 'keep executing the same line of code in a hope that retries will
  900.                 'be the solution to the problem.
  901.                 On Error GoTo BadTime_logParseItemConnect
  902.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  903.                 On Error goto 0
  904.             End If
  905.             Resume 0
  906.         End If
  907.     Else
  908.         'At MaxRetries, flag a failure in the routine
  909.         Success = False
  910.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  911.         'get a reason why the error occurred
  912.         ErrorCode = Err
  913.         objError.ErrorCode = Err
  914.         objError.FunctionName = "clsTime_log.ParseItem"
  915.         If Err = 3146 then
  916.             objError.Message = "Time_log, ParseItem " & vbcrlf & Errors(0) & " "
  917.             ErrorMessage = Errors(0)
  918.         Else
  919.             objError.Message = "Time_log, ParseItem "
  920.             ErrorMessage = Error(Err)
  921.         End If
  922.         objError.SQL = Buf1
  923.         objError.Display vbExclamation
  924.         'reset the counter
  925.         BadCount = 0
  926.         'and try to execute the next line of code in the routine
  927.         Resume Next
  928.     End If
  929.  
  930. BadTime_logParseItemConnect:
  931.     'You can put additional database reopening error checking here if necessary
  932.     Resume Next
  933.  
  934.  
  935. End Function
  936.  
  937.  
  938. '********************************************************************************************************
  939. 'Title:     UpdateItem
  940. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  941. 'Purpose:   This method updates a record in the database using the primary key, it is recommended that you
  942. '           Fill the Key Fields, use the get method, fill the fields which have changed, 
  943. '           then call this method to perform the update
  944. 'Parameters:None
  945. 'Return:    Nothing
  946. '********************************************************************************************************
  947. Public Sub UpdateItem()
  948.  
  949. Dim lsUpdate as string
  950. Dim RetCode as integer, liCount as integer, BadCount as integer
  951.  
  952.     'The Success flag gets initialized to True and set to false if a trappable error occurs
  953.     Success = True
  954.     'The ErrorCode is the Err returned by VB for the Trapped Error
  955.     ErrorCode = False
  956.     'The DebugFlag is the provision which turns off all error checking in the table class when false
  957.     If Not objConfiguration.DebugFlag Then
  958.         On Error GoTo NoTime_logUpdateItem
  959.     End If
  960.  
  961.     'First we will assign the date properties to temp vars and set any blank dates to NULL, or put in the date delimiters (Database Dependent)
  962.     StoreProperties
  963.     SetDefaultDates
  964.  
  965.     'Now Pad fields with a space if the record cannot be added with zero length
  966.     PadFields
  967.  
  968.     'The Double Your Quotes routine doubles any single quotes in string type variables for SQL compatibility
  969.     DoubleYourQuotes
  970.  
  971.     'Assemble the SQL String
  972.     lsUpdate = "Update TIME_LOG Set "
  973.     lsUpdate = lsUpdate & "Rate = " & Format(Rate) & ","
  974.     lsUpdate = lsUpdate & "In_Time1 = " & In_Time1 & ","
  975.     lsUpdate = lsUpdate & "Out_Time1 = " & Out_Time1 & ","
  976.     lsUpdate = lsUpdate & "In_Time2 = " & In_Time2 & ","
  977.     lsUpdate = lsUpdate & "Out_Time2 = " & Out_Time2 & ","
  978.     lsUpdate = lsUpdate & "Total_Time = " & Format(Total_Time) & ","
  979.     lsUpdate = lsUpdate & "Comments = '" & Comments & "',"
  980.     'These are the Audit Trail Fields
  981.     lsUpdate = lsUpdate & "Updated_By = '" & objConfiguration.LanId & "',"
  982.     lsUpdate = lsUpdate & "Update_Module = '" & objConfiguration.ModuleName & "',"
  983.     lsUpdate = lsUpdate & "Update_Time = #" & format(Now,"MM/DD/YYYY hh:mm:ss") & "# "
  984.     lsUpdate = lsUpdate & " where Reporting_Day = " & Reporting_Day & " and Client = " & Format(Client) & ""
  985.  
  986.     'Execute the SQL
  987.     Dbtimesheet.Execute lsUpdate
  988.  
  989.     'now reassign the temp values back to the properties
  990.     RetrieveProperties
  991.  
  992.     On Error GoTo 0
  993.     Exit Sub
  994.  
  995. NoTime_logUpdateItem:
  996.  
  997.     'Retry for a predermined number of times, set by the MaxRetries Constant
  998.     If BadCount < MaxRetries Then
  999.         'if we have been exceeded retries on a previous error in this routine,
  1000.         'just give the remaining errors one try, and don't save these errors,
  1001.         'the interest should be in the original error
  1002.         If Success = False Then
  1003.             Resume Next
  1004.         Else
  1005.             'increment the retry counter
  1006.             BadCount = BadCount + 1
  1007.             'Look for Database errors and see if you can fix the error by reconnecting
  1008.             If Err = 3146 or Err = 3075 then
  1009.                 'Try Reconnecting to the database, then
  1010.                 'keep executing the same line of code in a hope that retries will
  1011.                 'be the solution to the problem.
  1012.                 On Error GoTo BadTime_logUpdateItemConnect
  1013.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1014.                 On Error goto 0
  1015.             End If
  1016.             Resume 0
  1017.         End If
  1018.     Else
  1019.         'At MaxRetries, flag a failure in the routine
  1020.         Success = False
  1021.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1022.         'get a reason why the error occurred
  1023.         ErrorCode = Err
  1024.         objError.ErrorCode = Err
  1025.         objError.FunctionName = "clsTime_log.UpdateItem"
  1026.         If Err = 3146 then
  1027.             objError.Message = "Time_log, UpdateItem " & vbcrlf & Errors(0) & " "
  1028.             ErrorMessage = Errors(0)
  1029.         Else
  1030.             objError.Message = "Time_log, UpdateItem "
  1031.             ErrorMessage = Error(Err)
  1032.         End If
  1033.         objError.SQL = lsUpdate
  1034.         objError.Display vbExclamation
  1035.         'reset the counter
  1036.         BadCount = 0
  1037.         'and try to execute the next line of code in the routine
  1038.         Resume Next
  1039.     End If
  1040.  
  1041. BadTime_logUpdateItemConnect:
  1042.     'You can put additional database reopening error checking here if necessary
  1043.     Resume Next
  1044.  
  1045.  
  1046. End Sub
  1047.  
  1048. '********************************************************************************************************
  1049. 'Title:     DoubleYourQuotes
  1050. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1051. 'Purpose:   This routine Doubles your Single Quotes in all string or memo 
  1052. '           fields in the class for SQL compatibility
  1053. 'Parameters:None
  1054. 'Return:    Nothing
  1055. '********************************************************************************************************
  1056. Private Sub DoubleYourQuotes()
  1057.  
  1058. Dim liCount as integer,BadCount as integer
  1059.  
  1060.     If Not objConfiguration.DebugFlag Then
  1061.         On Error GoTo NoTime_logDoubleYourQuotes
  1062.     End If
  1063.  
  1064.     'These lines double the single quotes in any string field in the class
  1065.     Comments = SearchandDouble(Comments)
  1066.     Updated_By = SearchandDouble(Updated_By)
  1067.     Update_Module = SearchandDouble(Update_Module)
  1068.     On Error GoTo 0
  1069.     Exit Sub
  1070.  
  1071. NoTime_logDoubleYourQuotes:
  1072.  
  1073.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1074.     If BadCount < MaxRetries Then
  1075.         'if we have been exceeded retries on a previous error in this routine,
  1076.         'just give the remaining errors one try, and don't save these errors,
  1077.         'the interest should be in the original error
  1078.         If Success = False Then
  1079.             Resume Next
  1080.         Else
  1081.             'increment the retry counter
  1082.             BadCount = BadCount + 1
  1083.             'Look for Database errors and see if you can fix the error by reconnecting
  1084.             If Err = 3146 or Err = 3075 then
  1085.                 'Try Reconnecting to the database, then
  1086.                 'keep executing the same line of code in a hope that retries will
  1087.                 'be the solution to the problem.
  1088.                 On Error GoTo BadTime_logDoubleYourQuotesConnect
  1089.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1090.                 On Error goto 0
  1091.             End If
  1092.             Resume 0
  1093.         End If
  1094.     Else
  1095.         'At MaxRetries, flag a failure in the routine
  1096.         Success = False
  1097.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1098.         'get a reason why the error occurred
  1099.         ErrorCode = Err
  1100.         objError.ErrorCode = Err
  1101.         objError.FunctionName = "clsTime_log.DoubleYourQuotes"
  1102.         If Err = 3146 then
  1103.             objError.Message = "Time_log, DoubleYourQuotes " & vbcrlf & Errors(0) & " "
  1104.             ErrorMessage = Errors(0)
  1105.         Else
  1106.             objError.Message = "Time_log, DoubleYourQuotes "
  1107.             ErrorMessage = Error(Err)
  1108.         End If
  1109.         objError.SQL = ""
  1110.         objError.Display vbExclamation
  1111.         'reset the counter
  1112.         BadCount = 0
  1113.         'and try to execute the next line of code in the routine
  1114.         Resume Next
  1115.     End If
  1116.  
  1117. BadTime_logDoubleYourQuotesConnect:
  1118.     'You can put additional database reopening error checking here if necessary
  1119.     Resume Next
  1120.  
  1121.  
  1122. End Sub
  1123.  
  1124. '********************************************************************************************************
  1125. 'Title:     SearchandDouble
  1126. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1127. 'Purpose:   This Function will look for any single quotes in a string passed to it
  1128. '           and double them for SQL compatibility
  1129. 'Parameters:string to be modified
  1130. 'Return:    the modified string
  1131. '********************************************************************************************************
  1132. Private Function SearchandDouble(lsBuf As String) As String
  1133.  
  1134. Dim liStrLen As Integer
  1135. Dim liCurChar As Integer
  1136. Dim liQuotePos As Integer
  1137. Dim lsQuote As String
  1138. Dim lsOutBuf As String
  1139.  
  1140.     lsQuote = "'"
  1141.     liCurChar = 1
  1142.     lsOutBuf = ""
  1143.     
  1144.     
  1145.     liQuotePos = InStr(liCurChar, lsBuf, lsQuote)
  1146.     If liQuotePos = 0 Then
  1147.         lsOutBuf = lsBuf
  1148.     Else
  1149.         liStrLen = Len(lsBuf)
  1150.         Do While liQuotePos > 0
  1151.             lsOutBuf = lsOutBuf & Mid(lsBuf, liCurChar, liQuotePos - liCurChar + 1) & lsQuote
  1152.             liCurChar = liQuotePos + 1
  1153.             liQuotePos = InStr(liCurChar, lsBuf, lsQuote)
  1154.         Loop
  1155.         lsOutBuf = lsOutBuf & Mid(lsBuf, liCurChar, liStrLen)
  1156.     End If
  1157.  
  1158.     SearchandDouble = lsOutBuf
  1159.  
  1160. End Function
  1161.  
  1162. '********************************************************************************************************
  1163. 'Title:     SetDefaultDates
  1164. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1165. 'Purpose:   This routine puts default date or NULL into blank or invalid date fields
  1166. 'Parameters:None
  1167. 'Return:    Nothing
  1168. '********************************************************************************************************
  1169. Private Sub SetDefaultDates()
  1170.  
  1171. Dim liCount as integer,BadCount as integer
  1172.  
  1173.     If Not objConfiguration.DebugFlag Then
  1174.         On Error GoTo NoTime_logSetDefaultDates
  1175.     End If
  1176.  
  1177.     'These lines look at the dates in the class, and put a NULL or your default date
  1178.      'depending on your data mode, when the date is
  1179.     'blank or invalid, since this is what sql expects
  1180.     if not isDate(Reporting_Day) then
  1181.         Reporting_Day = "NULL"
  1182.     Else
  1183.         Reporting_Day = "#" & format(CDate(Reporting_Day),"MM/DD/YYYY HH:MM:SS") & "#"
  1184.     Endif
  1185.     if not isDate(In_Time1) then
  1186.         In_Time1 = "NULL"
  1187.     Else
  1188.         In_Time1 = "#" & format(CDate(In_Time1),"MM/DD/YYYY HH:MM:SS") & "#"
  1189.     Endif
  1190.     if not isDate(Out_Time1) then
  1191.         Out_Time1 = "NULL"
  1192.     Else
  1193.         Out_Time1 = "#" & format(CDate(Out_Time1),"MM/DD/YYYY HH:MM:SS") & "#"
  1194.     Endif
  1195.     if not isDate(In_Time2) then
  1196.         In_Time2 = "NULL"
  1197.     Else
  1198.         In_Time2 = "#" & format(CDate(In_Time2),"MM/DD/YYYY HH:MM:SS") & "#"
  1199.     Endif
  1200.     if not isDate(Out_Time2) then
  1201.         Out_Time2 = "NULL"
  1202.     Else
  1203.         Out_Time2 = "#" & format(CDate(Out_Time2),"MM/DD/YYYY HH:MM:SS") & "#"
  1204.     Endif
  1205.     if not isDate(Update_Time) then
  1206.         Update_Time = "NULL"
  1207.     Else
  1208.         Update_Time = "#" & format(CDate(Update_Time),"MM/DD/YYYY HH:MM:SS") & "#"
  1209.     Endif
  1210.     On Error GoTo 0
  1211.     Exit Sub
  1212.  
  1213. NoTime_logSetDefaultDates:
  1214.  
  1215.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1216.     If BadCount < MaxRetries Then
  1217.         'if we have been exceeded retries on a previous error in this routine,
  1218.         'just give the remaining errors one try, and don't save these errors,
  1219.         'the interest should be in the original error
  1220.         If Success = False Then
  1221.             Resume Next
  1222.         Else
  1223.             'increment the retry counter
  1224.             BadCount = BadCount + 1
  1225.             'Look for Database errors and see if you can fix the error by reconnecting
  1226.             If Err = 3146 or Err = 3075 then
  1227.                 'Try Reconnecting to the database, then
  1228.                 'keep executing the same line of code in a hope that retries will
  1229.                 'be the solution to the problem.
  1230.                 On Error GoTo BadTime_logSetDefaultDatesConnect
  1231.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1232.                 On Error goto 0
  1233.             End If
  1234.             Resume 0
  1235.         End If
  1236.     Else
  1237.         'At MaxRetries, flag a failure in the routine
  1238.         Success = False
  1239.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1240.         'get a reason why the error occurred
  1241.         ErrorCode = Err
  1242.         objError.ErrorCode = Err
  1243.         objError.FunctionName = "clsTime_log.SetDefaultDates"
  1244.         If Err = 3146 then
  1245.             objError.Message = "Time_log, SetDefaultDates " & vbcrlf & Errors(0) & " "
  1246.             ErrorMessage = Errors(0)
  1247.         Else
  1248.             objError.Message = "Time_log, SetDefaultDates "
  1249.             ErrorMessage = Error(Err)
  1250.         End If
  1251.         objError.SQL = ""
  1252.         objError.Display vbExclamation
  1253.         'reset the counter
  1254.         BadCount = 0
  1255.         'and try to execute the next line of code in the routine
  1256.         Resume Next
  1257.     End If
  1258.  
  1259. BadTime_logSetDefaultDatesConnect:
  1260.     'You can put additional database reopening error checking here if necessary
  1261.     Resume Next
  1262.  
  1263.  
  1264. End Sub
  1265.  
  1266. '********************************************************************************************************
  1267. 'Title:     StripDates
  1268. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1269. 'Purpose:   This routine strips NULLS and bad Dates from Fields in the class, the delimiter field
  1270. '           determines whether it should check for the presence of Date Delimiters
  1271. 'Parameters:None
  1272. 'Return:    Nothing
  1273. '********************************************************************************************************
  1274. Private Sub StripDates(DelimiterFlag as integer)
  1275.  
  1276. Dim liCount as integer,BadCount as integer
  1277.  
  1278.     If Not objConfiguration.DebugFlag Then
  1279.         On Error GoTo NoTime_logStripDates
  1280.     End If
  1281.  
  1282.     'These lines check to see if a NULL has been entered into the field from the
  1283.     'DefaultDate subroutine, if it has, it is set to an empty string, the date from
  1284.     'the database is also checked, if it is invalid, it to is set to an empty string
  1285.     if Reporting_Day = "NULL" then
  1286.         Reporting_Day = ""
  1287.     Endif
  1288.     if In_Time1 = "NULL" then
  1289.         In_Time1 = ""
  1290.     Endif
  1291.     if Out_Time1 = "NULL" then
  1292.         Out_Time1 = ""
  1293.     Endif
  1294.     if In_Time2 = "NULL" then
  1295.         In_Time2 = ""
  1296.     Endif
  1297.     if Out_Time2 = "NULL" then
  1298.         Out_Time2 = ""
  1299.     Endif
  1300.     if Update_Time = "NULL" then
  1301.         Update_Time = ""
  1302.     Endif
  1303.     On Error GoTo 0
  1304.     Exit Sub
  1305.  
  1306. NoTime_logStripDates:
  1307.  
  1308.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1309.     If BadCount < MaxRetries Then
  1310.         'if we have been exceeded retries on a previous error in this routine,
  1311.         'just give the remaining errors one try, and don't save these errors,
  1312.         'the interest should be in the original error
  1313.         If Success = False Then
  1314.             Resume Next
  1315.         Else
  1316.             'increment the retry counter
  1317.             BadCount = BadCount + 1
  1318.             'Look for Database errors and see if you can fix the error by reconnecting
  1319.             If Err = 3146 or Err = 3075 then
  1320.                 'Try Reconnecting to the database, then
  1321.                 'keep executing the same line of code in a hope that retries will
  1322.                 'be the solution to the problem.
  1323.                 On Error GoTo BadTime_logStripDatesConnect
  1324.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1325.                 On Error goto 0
  1326.             End If
  1327.             Resume 0
  1328.         End If
  1329.     Else
  1330.         'At MaxRetries, flag a failure in the routine
  1331.         Success = False
  1332.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1333.         'get a reason why the error occurred
  1334.         ErrorCode = Err
  1335.         objError.ErrorCode = Err
  1336.         objError.FunctionName = "clsTime_log.StripDates"
  1337.         If Err = 3146 then
  1338.             objError.Message = "Time_log, StripDates " & vbcrlf & Errors(0) & " "
  1339.             ErrorMessage = Errors(0)
  1340.         Else
  1341.             objError.Message = "Time_log, StripDates "
  1342.             ErrorMessage = Error(Err)
  1343.         End If
  1344.         objError.SQL = ""
  1345.         objError.Display vbExclamation
  1346.         'reset the counter
  1347.         BadCount = 0
  1348.         'and try to execute the next line of code in the routine
  1349.         Resume Next
  1350.     End If
  1351.  
  1352. BadTime_logStripDatesConnect:
  1353.     'You can put additional database reopening error checking here if necessary
  1354.     Resume Next
  1355.  
  1356.  
  1357. End Sub
  1358.  
  1359. '********************************************************************************************************
  1360. 'Title:     PadFields
  1361. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1362. 'Purpose:   This routine Pads any fields with a space which do not allow zero length
  1363. 'Purpose:   The Allow zero length property is set by default in Access databases and is
  1364. '           used also in Oracle and SQLServer if the if fields are not padded with space
  1365. '           the database won't add the record, sometimes this is desirable sometimes not
  1366. 'Parameters:None
  1367. 'Return:    Nothing
  1368. '********************************************************************************************************
  1369. Private Sub PadFields()
  1370.  
  1371. Dim liCount as integer,BadCount as integer
  1372.  
  1373.     If Not objConfiguration.DebugFlag Then
  1374.         On Error GoTo NoTime_logPadFields
  1375.     End If
  1376.  
  1377.     'These lines put a space into any field which does not allow zero length, so the
  1378.     'record can be added anyway
  1379.     On Error GoTo 0
  1380.     Exit Sub
  1381.  
  1382. NoTime_logPadFields:
  1383.  
  1384.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1385.     If BadCount < MaxRetries Then
  1386.         'if we have been exceeded retries on a previous error in this routine,
  1387.         'just give the remaining errors one try, and don't save these errors,
  1388.         'the interest should be in the original error
  1389.         If Success = False Then
  1390.             Resume Next
  1391.         Else
  1392.             'increment the retry counter
  1393.             BadCount = BadCount + 1
  1394.             'Look for Database errors and see if you can fix the error by reconnecting
  1395.             If Err = 3146 or Err = 3075 then
  1396.                 'Try Reconnecting to the database, then
  1397.                 'keep executing the same line of code in a hope that retries will
  1398.                 'be the solution to the problem.
  1399.                 On Error GoTo BadTime_logPadFieldsConnect
  1400.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1401.                 On Error goto 0
  1402.             End If
  1403.             Resume 0
  1404.         End If
  1405.     Else
  1406.         'At MaxRetries, flag a failure in the routine
  1407.         Success = False
  1408.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1409.         'get a reason why the error occurred
  1410.         ErrorCode = Err
  1411.         objError.ErrorCode = Err
  1412.         objError.FunctionName = "clsTime_log.PadFields"
  1413.         If Err = 3146 then
  1414.             objError.Message = "Time_log, PadFields " & vbcrlf & Errors(0) & " "
  1415.             ErrorMessage = Errors(0)
  1416.         Else
  1417.             objError.Message = "Time_log, PadFields "
  1418.             ErrorMessage = Error(Err)
  1419.         End If
  1420.         objError.SQL = ""
  1421.         objError.Display vbExclamation
  1422.         'reset the counter
  1423.         BadCount = 0
  1424.         'and try to execute the next line of code in the routine
  1425.         Resume Next
  1426.     End If
  1427.  
  1428. BadTime_logPadFieldsConnect:
  1429.     'You can put additional database reopening error checking here if necessary
  1430.     Resume Next
  1431.  
  1432.  
  1433. End Sub
  1434.  
  1435. '********************************************************************************************************
  1436. 'Title:     TrimPaddedFields
  1437. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1438. 'Purpose:   This routine Trims the fields which have spaces at beginning or end
  1439. 'Parameters:None
  1440. 'Return:    Nothing
  1441. '********************************************************************************************************
  1442. Private Sub TrimPaddedFields()
  1443.  
  1444. Dim liCount as integer,BadCount as integer
  1445.  
  1446.     If Not objConfiguration.DebugFlag Then
  1447.         On Error GoTo NoTime_logTrimPaddedFields
  1448.     End If
  1449.  
  1450.     'This routine deletes the spaces from any padded fields
  1451.     On Error GoTo 0
  1452.     Exit Sub
  1453.  
  1454. NoTime_logTrimPaddedFields:
  1455.  
  1456.     'Retry for a predermined number of times, set by the MaxRetries Constant
  1457.     If BadCount < MaxRetries Then
  1458.         'if we have been exceeded retries on a previous error in this routine,
  1459.         'just give the remaining errors one try, and don't save these errors,
  1460.         'the interest should be in the original error
  1461.         If Success = False Then
  1462.             Resume Next
  1463.         Else
  1464.             'increment the retry counter
  1465.             BadCount = BadCount + 1
  1466.             'Look for Database errors and see if you can fix the error by reconnecting
  1467.             If Err = 3146 or Err = 3075 then
  1468.                 'Try Reconnecting to the database, then
  1469.                 'keep executing the same line of code in a hope that retries will
  1470.                 'be the solution to the problem.
  1471.                 On Error GoTo BadTime_logTrimPaddedFieldsConnect
  1472.                 Set Dbtimesheet = OpenDatabase(Objconfiguration.datasource)
  1473.                 On Error goto 0
  1474.             End If
  1475.             Resume 0
  1476.         End If
  1477.     Else
  1478.         'At MaxRetries, flag a failure in the routine
  1479.         Success = False
  1480.         'set the ErrorCode and ErrorMessage Properties so the programmer can
  1481.         'get a reason why the error occurred
  1482.         ErrorCode = Err
  1483.         objError.ErrorCode = Err
  1484.         objError.FunctionName = "clsTime_log.TrimPaddedFields"
  1485.         If Err = 3146 then
  1486.             objError.Message = "Time_log, TrimPaddedFields " & vbcrlf & Errors(0) & " "
  1487.             ErrorMessage = Errors(0)
  1488.         Else
  1489.             objError.Message = "Time_log, TrimPaddedFields "
  1490.             ErrorMessage = Error(Err)
  1491.         End If
  1492.         objError.SQL = ""
  1493.         objError.Display vbExclamation
  1494.         'reset the counter
  1495.         BadCount = 0
  1496.         'and try to execute the next line of code in the routine
  1497.         Resume Next
  1498.     End If
  1499.  
  1500. BadTime_logTrimPaddedFieldsConnect:
  1501.     'You can put additional database reopening error checking here if necessary
  1502.     Resume Next
  1503.  
  1504.  
  1505. End Sub
  1506.  
  1507.  
  1508. '********************************************************************************************************
  1509. 'Title:     StoreProperties
  1510. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1511. 'Purpose    This Sub Assigns the Properties of the Class to the
  1512. '           private class scratchpad variables
  1513. 'Parameters:None
  1514. 'Return:    Nothing
  1515. '********************************************************************************************************
  1516. Private Sub StoreProperties()
  1517.  
  1518.     mReporting_Day = Reporting_Day
  1519.     mClient = Client
  1520.     mRate = Rate
  1521.     mIn_Time1 = In_Time1
  1522.     mOut_Time1 = Out_Time1
  1523.     mIn_Time2 = In_Time2
  1524.     mOut_Time2 = Out_Time2
  1525.     mTotal_Time = Total_Time
  1526.     mComments = Comments
  1527.     mUpdated_By = Updated_By
  1528.     mUpdate_Module = Update_Module
  1529.     mUpdate_Time = Update_Time
  1530.  
  1531. End Sub
  1532.  
  1533. '********************************************************************************************************
  1534. 'Title:     RetrieveProperties
  1535. 'Author:    DesignGrid by W. David Ewing, Copyright 1998
  1536. 'Purpose    This Sub Assigns the ScratchPad Variable Values back to the Class properties
  1537. 'Parameters:None
  1538. 'Return:    Nothing
  1539. '********************************************************************************************************
  1540. Private Sub RetrieveProperties()
  1541.  
  1542.     Reporting_Day = mReporting_Day
  1543.     Client = mClient
  1544.     Rate = mRate
  1545.     In_Time1 = mIn_Time1
  1546.     Out_Time1 = mOut_Time1
  1547.     In_Time2 = mIn_Time2
  1548.     Out_Time2 = mOut_Time2
  1549.     Total_Time = mTotal_Time
  1550.     Comments = mComments
  1551.     Updated_By = mUpdated_By
  1552.     Update_Module = mUpdate_Module
  1553.     Update_Time = mUpdate_Time
  1554.  
  1555. End Sub
  1556.